<#assign classNameLower = ClassName ? uncap_first>
package ${pPackage}.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

import ${pPackage}.common.entity.Result;
import ${pPackage}.common.entity.ResultCode;
import ${pPackage}.common.entity.PageResult;
import ${pPackage}.common.exception.CommonException;

import ${pPackage}.service.impl.${ClassName}Service;
import ${pPackage}.pojo.${ClassName};
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Api(tags = "${table.comment}")
@RestController
@RequestMapping(value="/api/${classNameLower}")
public class ${ClassName}Controller {

    @Autowired
    private ${ClassName}Service ${classNameLower}Service;

    @ApiOperation(value = "新增")
    @PostMapping("")
    public Result save(@RequestBody ${ClassName} ${classNameLower})  {
        ${classNameLower}Service.add(${classNameLower});
        return Result.SUCCESS();
    }

    @ApiOperation(value = "根据id更新")
    @PutMapping("")
    public Result update(@RequestBody ${ClassName} ${classNameLower} ) throws CommonException {
        ${classNameLower}Service.update(${classNameLower});
        return Result.SUCCESS();
    }

    @ApiOperation(value = "根据id删除")
    @DeleteMapping("/{id}")
    public Result delete(@PathVariable(value="id") String id) throws CommonException {
        ${classNameLower}Service.deleteById(id);
        return Result.SUCCESS();
    }

    @ApiOperation(value = "根据id查询")
    @GetMapping("/{id}")
    public Result<${ClassName}> findById(@PathVariable(value="id") String id) {
        return Result.SUCCESS(${classNameLower}Service.findById(id));
    }


    @ApiOperation(value = "分页查询")
    @PostMapping("{pageNum}/{pageSize}")
    public Result<PageResult<${ClassName}>> findPage(
      @PathVariable(value = "pageNum") Integer pageNum,
      @PathVariable(value = "pageSize") Integer pageSize,
      @RequestBody ${ClassName} ${classNameLower}
  ) throws CommonException {
        return Result.SUCCESS(${classNameLower}Service.findPage(${classNameLower}, pageNum, pageSize));
    }
}
